import { Base } from '../base.js';

class Pay extends Base {
	

	/*
	* 拉起微信支付
	* */
	getSignature(order_id) {
		var params = {
			url: 'v1/pay/pre_order',
			type: 'post',
			data: { id: order_id}
		}
		return	this.request(params);
	}
	
	/*
	*
	* 拉起微信支付收银台页面
	* 
	*/
	execPay(data, callback) {
		console.log(data)
		uni.requestPayment({
			provider:'wxpay',
			timeStamp: data.timeStamp.toString(),
			nonceStr: data.nonceStr,
			package: data.package,
			signType: data.signType,
			paySign: data.paySign,
			success: function (res) {
				console.log(res)
				console.log('sssssssssssssssssssssssssssssss')
				callback && callback(1);
			},
			fail: function (err) {
				console.log(err)
				console.log('fail')
				console.log('ffffffffffffffffffffffffffffffffffffff')
				callback && callback(2);
			}
		})
	}
};

export { Pay };